<template>
  <div>
    <bread class="filter">
      <h1 @click="back" class="back">
        <span class="el-icon-arrow-left icon"></span>返回
      </h1>
      <div class="filter-block">
        <search-box
          ref="searchBox"
          placeholder="搜索成果"
          :keyword="keyword"
          @search="getSearchWords"
          @clear="clearSearch"
          @active="hideFilter = true"
          @deactive="hideFilter = false">
        </search-box>
      </div>
      <div class="filter-block">
        <normal-filter
          :label="filters.text"
          @change="handleLanguage"
          :options="filters.dataset">
        </normal-filter>
      </div>
      <div class="pull-right">
        <el-button size="small" class="custom-button" plain>考核配置</el-button>
      </div>
    </bread>
    <pageContent hasPagination>
      <el-table
        :data="tableData"
        stripe
        style="width: 100%"
        header-row-class-name="custom-table-header">
        <el-table-column
          label="序号"
          type="index"
          width="100">
        </el-table-column>
        <template v-for="item in tableHead">
          <template v-if="item.en == 'b'">
            <el-table-column
              :label="item.cn"
              :key="item.en"
              :width="getColumnWidth(item)">
              <template slot-scope="scope">
                <router-link to="/index/research-assessment/author/id/91">{{scope.row.b}}</router-link>
              </template>
            </el-table-column>
          </template>
          <template v-else-if="item.en == 'd'">
            <el-table-column
              :label="item.cn"
              :key="item.en"
              :width="getColumnWidth(item)">
              <template slot-scope="scope">
                <template v-if="scope.row.d">
                  已结束
                </template>
                <template v-else>
                  <span class="primary-color">进行中</span>
                </template>
              </template>
            </el-table-column>
          </template>
          <template v-else>
            <el-table-column
              :prop="item.en"
              :label="item.cn"
              :key="item.en"
              :width="getColumnWidth(item)">
            </el-table-column>
          </template>
        </template>
      </el-table>
    </pageContent>
    <pagination
      :total="total"
      :page-size="pageSize"
      @changePage="fetchData">
    </pagination>
  </div>

</template>

<script>
import pagination from 'components/pagination';
import NormalFilter from 'components/NormalFilter';
import SearchBox from 'components/SearchBox';
import back from 'mixins/back';

export default {
  name: 'hello',
  mixins: [back],
  data () {
    return {
      keyword: null,
      hideFilter: true,
      tableHead: [
        {
          cn: '工号',
          en: 'a',
        },
        {
          cn: '姓名',
          en: 'b',
        },
        {
          cn: '学院',
          en: 'c',
        },
        {
          cn: '考核周期',
          en: 'd',
        },
        {
          cn: '自评',
          en: 'e',
        },
        {
          cn: '院评',
          en: 'f',
        },
        {
          cn: '校评',
          en: 'g',
        },
        {
          cn: '状态',
          en: 'h',
        },
        {
          cn: '提交时间',
          en: 'i',
        },
        {
          cn: '备注',
          en: 'j',
        },
      ],
      tableData: [
        {
          a: '1233',
          b: '刘山',
          c: '管理学院',
          d: '2017-01-01至2017-12-31',
          e: '955',
          f: '-',
          g: '-',
          h: '待校评',
          i: '2018-04-24',
          j: '-',
        },
        {
          a: '1234',
          b: '王珊珊',
          c: '管理学院',
          d: '2017-01-01至2017-12-31',
          e: '800',
          f: '1200',
          g: '980',
          h: '校退回',
          i: '2018-04-23',
          j: '专利成果信息不符',
        },
      ],
      total: 1000,
      pageSize: 30,
      filters: {
        dataset: [{txt: '全部', val: '0'}, {txt: '中文成果', val: '1'}, {txt: '英文成果', val: '2'}],
        text: '语言'
      }
    }
  },
  methods: {
    getColumnWidth(item) {
      switch (item.en) {
      case 'b':
        return 120;
      case 'd':
        return 100;
      case 'e':
        return 146;
      }
    },
    fetchData(page) {
      // console.log(page);
    },
    handleLanguage() {

    },
    reject() {
      this.$confirm('确认退回后，该老师需修改后重新提交', '是否退回 李丽霞 的考核？', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$message({
          type: 'success',
          message: '操作成功!'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消退回'
        });
      });
    },
    pass() {
    },
    getSearchWords() {

    },
    clearSearch() {

    },

  },
  components: {
    pagination,
    NormalFilter,
    SearchBox
  }
};
</script>
<style scoped lang="scss">
  .primary-color {
    color: var(--success-color);
  }
</style>
